package ca.mcgill.schedulability.singleevent.functional;

import java.util.ArrayList;
import java.util.List;

import ca.mcgill.model.digraph.Digraph;
import ca.mcgill.model.digraph.DigraphEdge;
import ca.mcgill.model.functional.State;
import ca.mcgill.model.functional.Transition;


public class DemandTuple {

	// demand pair <e, r, transition> 
	// where e=accumulated ExecTime, totalRequestedTime and
	// transition the last transition of the ExecPath
	
	private Transition transition;
	private double e;
	private double r;
	private List<Boolean> takenEdges;
	
	
	public DemandTuple(double e, double r, Transition transition) {
		this.transition = transition;
		this.e = e;
		this.r = r;
	}

	// transition 
	public Transition getTransition() {
		return transition;
	}

	public void setTransition(Transition transition) {
		this.transition = transition;
	}
	
	// exec times 
	public double getExecTime() {
		return e;
	}
	
	public void setExecTime(double e) {
		this.e = e;
	}
	
	
	// requested times 
	public double getRequestTime() {
		return r;
	}
	
	public void setRequestTime(double r) {
		this.r = r;
	}
	
	
	
	// v2 - extra infos for the dynamic implementation of Stigge's algorithm
	public DemandTuple(double e, double r, Transition transition, List<Boolean> takenEdges) {
		this.transition = transition;
		this.e = e;
		this.r = r;
		this.takenEdges = takenEdges;
	}
	
	// requested times 
	public List<Boolean> getTakenEdges() {
		return takenEdges;
	}
	
	public void setTakenEdges(List<Boolean> takenEdges) {
		this.takenEdges = takenEdges;
	}
	
	public void setTakenEdge(int index, boolean b) {
		this.takenEdges.set(index, b);
	}
	
	
	public void resetTakenEdges(Digraph myDigraph) {
				
		// create a dummy DTset to check 
		boolean addTakenEdge = false;
		this.takenEdges.add(addTakenEdge);			
		this.takenEdges.clear();
		
		for (DigraphEdge edge : myDigraph.getEdges()) {
			if (transition.equals(edge.getSrcVertex())) {
				this.takenEdges.add(addTakenEdge);
			}
		} // for all Digraph edges -> find the outgoing ones. 
	}
	
	
}
